﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.BL;

namespace WebUI.UserControls
{
    public partial class MenuItem : System.Web.UI.UserControl
    {

        RegionBL vRegionBL = new RegionBL();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                List<ThanhTu.GNC.Media.KQXS.DataAccess.DO.RegionDO> vRegionDOCollection = vRegionBL.SelectALL();
                FirstLevelMenuRepeater.DataSource = vRegionDOCollection;
                FirstLevelMenuRepeater.DataBind();

                if (vRegionDOCollection == null) { Response.Write("RegionDO is null"); }
            }
            catch (Exception ex)
            {
                Response.Write("MenuItem: " + ex.Message);
            }


        }

        protected void FirstLevelMenuRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {

            if (e.Item.DataItem != null)
            {
                try
                {
                    string regionID = DataBinder.Eval(e.Item.DataItem, "regionID").ToString().Trim();
                    ProvinceBL vProvinceBL = new ProvinceBL();
                    Repeater FourthLevelMenuRepeater = (Repeater)e.Item.FindControl("SecondLevelMenuRepeater");
                    FourthLevelMenuRepeater.DataSource = vProvinceBL.selectadd_IdRegion(regionID);
                    FourthLevelMenuRepeater.DataBind();
                }
                catch (Exception ex) { Response.Write("SubMenu: " + ex.Message); }
            }

        }


    }
}